home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / incl / LEDA.020+881 / impl / list_pq.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.8 KB  |  82 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  list_pq.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #include <LEDA/basic.h>
  16.  
  17.  
  18. class list_pq_elem
  19. {
  20.   friend class list_pq;
  21.  
  22.   GenPtr key;
  23.   GenPtr inf;
  24.  
  25.   list_pq_elem* succ;
  26.   list_pq_elem* pred;
  27.  
  28.   list_pq_elem(GenPtr k, GenPtr i, list_pq_elem* p, list_pq_elem* s) 
  29.   { key = k; 
  30.     inf = i; 
  31.     pred = p;
  32.     succ = s;
  33.    }
  34.  
  35.   LEDA_MEMORY(list_pq_elem)
  36.  
  37. };
  38.  
  39.  
  40. #define PRIO_IMPL      list_pq
  41. #define PRIO_IMPL_ITEM list_pq_item
  42.  
  43. typedef list_pq_elem* list_pq_item;
  44.  
  45.  
  46. #define PRIO_IMPL_DATA list_pq_item head;\
  47.                        int          count;
  48.  
  49.  
  50. #include <LEDA/impl/prio_impl.h>
  51.  
  52.  
  53.  
  54. inline list_pq::list_pq()    { head = nil; count = 0; }
  55. inline list_pq::list_pq(int) { error_handler(1,"no list_pq(int) constructor");}
  56. inline list_pq::list_pq(int,int) { error_handler(1,"no list_pq(int,int) constructor");}
  57. inline list_pq::~list_pq() { clear(); }
  58.  
  59. inline list_pq_item list_pq::first_item()              const { return head;   }
  60. inline list_pq_item list_pq::next_item(list_pq_item x) const { return x->succ;}
  61.  
  62. inline GenPtr list_pq::key(list_pq_item it) const { return it->key; }
  63. inline GenPtr list_pq::inf(list_pq_item it) const { return it->inf; }
  64.  
  65. inline void list_pq::del_min()  { del_item(find_min());   }
  66.  
  67. inline void list_pq::decrease_key(list_pq_item it, GenPtr x)  
  68. { copy_key(x);
  69.   clear_key(it->key);
  70.   it->key = x; 
  71.  }
  72.  
  73. inline void list_pq::change_inf(list_pq_item it, GenPtr y)
  74. { copy_inf(y);
  75.   clear_inf(it->inf);
  76.   it->inf = y; 
  77.  }
  78.  
  79. inline int  list_pq::size()  const  { return count; }
  80.  
  81.